/**
 * 
 */
package org.rk.core.auth.util;

import java.util.List;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.rk.core.auth.bean.ActiveUser;
import org.rk.core.common.constant.RkConst;
import org.rk.core.domain.menu.CoreAdminMenu;
import org.rk.core.domain.module.CoreModule;
import org.rk.core.user.userRole.CoreUserRole;

/**
 * @author Cavion(曹仁道)
 * @类描述：當前登陸用戶信息獲取
 * 2016年12月4日
 */
public class SecurityUtil{

	public static Subject getSubject(){
		Subject subject=SecurityUtils.getSubject();
		return subject;
	}
	public static Session getSession(){
		return getSubject().getSession();
	}
	public static ActiveUser getUser(){
		return (ActiveUser) getSession().getAttribute(RkConst.session_key.activeUser);
	}
	public static String getUserName(){
		return getUser().getUserName();
	}
	public static Long getUserId(){
		return getUser().getId();
	}
	public static List<CoreAdminMenu> getMenu(){
		return getUser().getMenuList();
	}
	public static List<CoreModule> getModule(){
		return getUser().getModuleList();
	}
	public static List<CoreUserRole> getRole(){
		return getUser().getUserRoleList();
	}

	public static boolean isAuthenticated() {
		return getSubject().isAuthenticated();
	}
	public static String getSessionId(){
		return (String) getSession().getId();
	}
}
